﻿Option Strict Off
Option Explicit On
Imports System.Runtime.InteropServices
Public Class SDK_AdminPAQ

    ' Se adiciona 1 (+ 1) a la longitud original contemplando
    ' el caracter nulo necesario al final de la cadena.
    Public Const kLongCodigo As Short = 30 + 1
    Public Const kLongNombre As Short = 60 + 1
    Public Const kLongNombreProducto As Short = 255 + 1
    Public Const kLongFecha As Short = 23 + 1
    Public Const kLongAbreviatura As Short = 3 + 1
    Public Const kLongCodValorClasif As Short = 3 + 1
    Public Const kLongTextoExtra As Short = 50 + 1
    Public Const kLongNumSerie As Short = 11 + 1
    Public Const kLongReferencia As Short = 20 + 1
    Public Const kLongSeries As Short = 30 + 1
    Public Const kLongDescripcion As Short = 60 + 1
    Public Const kLongNumeroExtInt As Short = 6 + 1
    Public Const kLongCodigoPostal As Short = 6 + 1
    Public Const kLongTelefono As Short = 15 + 1
    Public Const kLongEmailWeb As Short = 50 + 1
    Public Const kLongRFC As Short = 20 + 1
    Public Const kLongCURP As Short = 20 + 1
    Public Const kLongDesCorta As Short = 20 + 1
    Public Const kLongDenComercial As Short = 50 + 1
    Public Const kLongRepLegal As Short = 50 + 1
    Public Const kLongIdDocum As Short = 11 + 1
    Public Const kLongImporteExtra As Short = 8 + 1
    Public Const kLongTipoCliente As Short = 6 + 1
    Public Const kLongCostoPromedio As Short = 8 + 1

    '** MODIFICACION .NET
    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=4)> _
    Public Structure tDocumento
        Dim aFolio As Double
        Dim aNumMoneda As Int32
        Dim aTipoCambio As Double
        Dim aImporte As Double
        Dim aDescuentoDoc1 As Double
        Dim aDescuentoDoc2 As Double
        Dim aSistemaOrigen As Integer
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodigo)> Dim aCodConcepto As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongNumSerie)> Dim aSerie As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongFecha)> Dim aFecha As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodigo)> Dim aCodigoCteProv As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodigo)> Dim aCodigoAgente As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongReferencia)> Dim aReferencia As Byte()
        Dim aAfecta As Int32

    End Structure
    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=4)> _
    Public Structure tClientes
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodigo)> Dim cCodigoCliente As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongNombre)> Dim cRazonSocial As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongFecha)> Dim cFechaAlta As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongRFC)> Dim cRFC As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCURP)> Dim cCURP As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongDenComercial)> Dim cDenComercial As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongRepLegal)> Dim cRepLegal As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongNombre)> Dim cNombreMoneda As Byte()
        Dim cListaPreciosCliente As Int32
        Dim cDescuentoMovto As Double
        Dim cBanVentaCredito As Int32
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionCliente1 As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionCliente2 As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionCliente3 As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionCliente4 As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionCliente5 As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionCliente6 As Byte()
        Dim cTipoCliente As Int32
        Dim cEstatus As Int32
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongFecha)> Dim cFechaBaja As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongFecha)> Dim cFechaUltimaRevision As Byte()
        Dim cLimiteCreditoCliente As Double
        Dim cDiasCreditoCliente As Int32
        Dim cBanExcederCredito As Int32
        Dim cDescuentoProntoPago As Double
        Dim cDiasProntoPago As Int32
        Dim cInteresMotarotiro As Double
        Dim cDiasPago As Int32
        Dim cDiasRevision As Int32
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongDesCorta)> Dim cMensajeria As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongDescripcion)> Dim cCuentaMensajeria As Byte()
        Dim cDiasEmbarqueCliente As Int32
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodigo)> Dim cCodigoAlmacen As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodigo)> Dim cCodigoAgenteVenta As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodigo)> Dim cCodigoAgenteCobro As Byte()
        Dim cRestriccionAgente As Int32
        Dim cImpuesto1 As Double
        Dim cImpuesto2 As Double
        Dim cImpuesto3 As Double
        Dim cRetencionCliente1 As Double
        Dim cRetencionCliente2 As Double
        '<MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionProveedor1 As Byte()
        '<MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionProveedor2 As Byte()
        '<MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionProveedor3 As Byte()
        '<MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionProveedor4 As Byte()
        '<MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionProveedor5 As Byte()
        '<MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodValorClasif)> Dim cCodigoValorClasificacionProveedor6 As Byte()
        'Dim cLimiteCreditoProveedor As Double
        'Dim cDiasCreditoProveedor As Int32
        'Dim cTiempoEntrega As Int32
        'Dim cDiasEmbarqueProveedor As Int32
        'Dim cImpuestoProveedor1 As Double
        'Dim cImpuestoProveedor2 As Double
        'Dim cImpuestoProveedor3 As Double
        'Dim cRetencionProveedor1 As Double
        'Dim cRetencionProveedor2 As Double
        'Dim cBanInteresMoratorio As Int32
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongTextoExtra)> Dim cTextoExtra1 As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongTextoExtra)> Dim cTextoExtra2 As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongTextoExtra)> Dim cTextoExtra3 As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongTextoExtra)> Dim cTextoExtra4 As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongTextoExtra)> Dim cTextoExtra5 As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongFecha)> Dim cFechaExtra As Byte()
        Dim cImporteExtra1 As Double
        Dim cImporteExtra2 As Double
        Dim cImporteExtra3 As Double
        Dim cImporteExtra4 As Double
    End Structure
    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=4)> _
    Public Structure tLlaveDocto
        Dim aConsecutivo As Int32
        Dim aUnidades As Double
        Dim aPrecio As Double
        Dim aCosto As Double
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodigo)> Dim aCodProdSer As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodigo)> Dim aCodAlmacen As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongNumSerie)> Dim aReferencia As Byte()
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=kLongCodigo)> Dim aCodClasificacion As Byte()
        Dim aFolio As Double
    End Structure
    '__________________DECLARACIÓN DE LAS FUNCIONES DEL SDK______________________

    ' ***** Funciones Generales del SDK *****
    ' Inicialización/Terminación
    Public Declare Function fSetNombrePAQ Lib "MGW_SDK.DLL" (ByVal aNombre As String) As Long
    Public Declare Sub fNoApagarMotorBD Lib "MGW_SDK.DLL" ()
    Public Declare Function fInicializaSDK Lib "MGW_SDK.DLL" () As Integer
    Public Declare Sub fTerminaSDK Lib "MGW_SDK.DLL" ()
    Public Declare Function SetCurrentDirectory Lib "KERNEL32" Alias "SetCurrentDirectoryA" (ByVal pPtrDirActual As String) As Integer
    ' Manejo de errores
    Public Declare Sub fError Lib "MGW_SDK.DLL" (ByVal aNumError As Integer, ByVal aError As String, ByVal aLen As Integer)


    ' ***** Funciones de Empresas *****
    ' Navegación
    Declare Function fPosPrimerEmpresa Lib "MGW_SDK.DLL" (ByRef aIdEmpresa As Integer, ByVal aNombreEmpresa As String, ByVal aDirectorioEmpresa As String) As Integer
    Declare Function fPosSiguienteEmpresa Lib "MGW_SDK.DLL" (ByRef aIdEmpresa As Integer, ByVal aNombreEmpresa As String, ByVal aDirectorioEmpresa As String) As Integer
    ' Apertura/Cierre
    Declare Function fAbreEmpresa Lib "MGW_SDK.DLL" (ByVal aError As String) As Integer
    Public Declare Sub fCierraEmpresa Lib "MGW_SDK.DLL" ()



    ' ***** Funciones de Documentos *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fInsertarDocumento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fEditarDocumento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fGuardaDocumento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelarModificacionDocumento Lib "MGW_SDK.DLL" () As Integer

    Declare Function fBorraDocumento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelaDocumento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fBorraDocumento_CW Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelaDocumento_CW Lib "MGW_SDK.DLL" () As Integer

    'Todos los documentos creados con el SDK deben afectarse a fin de que se actualicen los acumulados del sistema
    Declare Function fAfectaDocto_Param Lib "MGW_SDK.DLL" (ByVal aCodConcepto As String, ByVal aSerie As String, ByVal aFolio As Double, ByVal aAfecta As Boolean) As Integer
    Declare Function fSaldarDocumento_Param Lib "MGW_SDK.DLL" (ByVal aCodConcepto_Pagar As String, ByVal aSerie_Pagar As String, ByVal aFolio_Pagar As Double, ByVal aCodConcepto_Pago As String, ByVal aSerie_Pago As String, ByVal aFolio_Pago As Double, ByVal aImporte As Double, ByVal aIdMoneda As Integer, ByVal aFecha As String) As Integer
    Declare Function fBorrarAsociacion_Param Lib "MGW_SDK.DLL" (ByVal aCodConcepto_Pagar As String, ByVal aSerie_Pagar As String, ByVal aFolio_Pagar As Double, ByVal aCodConcepto_Pago As String, ByVal aSerie_Pago As String, ByVal aFolio_Pago As Double) As Integer

    Declare Function fSetDatoDocumento Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String) As Integer
    Declare Function fLeeDatoDocumento Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String) As Integer
    Declare Function fLeeDatoDocumento Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer
    Declare Function fSiguienteFolio Lib "MGW_SDK.DLL" (ByVal aCodigoConcepto As String, ByVal aSerie As String, ByRef aFolio As Double) As Integer

    Declare Function fSetFiltroDocumento Lib "MGW_SDK.DLL" (ByVal aFechaInicio As String, ByVal aFechaFin As String, ByVal aCodigoConcepto As String, ByVal aCodigoCteProv As String) As Integer
    Declare Function fCancelaFiltroDocumento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fDocumentoImpreso Lib "MGW_SDK.DLL" (ByVal aImpreso As Boolean) As Integer

    ' Bajo Nivel - Busqueda/Navegación
    Declare Function fBuscarDocumento Lib "MGW_SDK.DLL" (ByVal aCodConcepto As String, ByVal aSerie As String, ByVal aFolio As String) As Integer
    Declare Function fBuscarIdDocumento Lib "MGW_SDK.DLL" (ByVal aIdDocumento As Integer) As Integer

    Declare Function fPosPrimerDocumento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosUltimoDocumento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosSiguienteDocumento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosAnteriorDocumento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosBOF Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosEOF Lib "MGW_SDK.DLL" () As Integer

    Declare Function fAltaDocumento Lib "MGW_SDK.DLL" (ByRef aIdDocumento As Integer, ByRef aDocto As tDocumento) As Integer
    Declare Function fAltaDocumentoCargoAbono Lib "MGW_SDK.DLL" (ByRef aDocto As tDocumento) As Integer
    Declare Function fAfectaDocto Lib "MGW_SDK.DLL" (ByRef astDocAPagar As tLlaveDocto, ByVal aAfecta As Boolean) As Integer
    Declare Function fSaldarDocumento Lib "MGW_SDK.DLL" (ByVal astDocAPagar As tLlaveDocto, ByVal astDocPago As tLlaveDocto, ByVal aImporte As Double, ByVal aIdMoneda As Integer, ByVal aFecha As String) As Integer
    Declare Function fBuscaDocumento Lib "MGW_SDK.DLL" (ByRef aLlaveDocto As tLlaveDocto) As Integer


    ' ***** Funciones de Movimientos  *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fInsertarMovimiento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fEditarMovimiento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fGuardaMovimiento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelaCambiosMovimiento Lib "MGW_SDK.DLL" () As Integer

    Declare Function fAltaMovimientoCaracteristicas_Param Lib "MGW_SDK.DLL" (ByVal aIdMovimiento As String, ByVal aIdMovtoCaracteristicas As String, ByVal aUnidades As String, ByVal aValorCaracteristica1 As String, ByVal aValorCaracteristica2 As String, ByVal aValorCaracteristica3 As String) As Integer
    Declare Function fAltaMovimientoSeriesCapas_Param Lib "MGW_SDK.DLL" (ByVal aIdMovimiento As String, ByVal aIdMovtoCaracteristicas As String, ByVal aUnidad As String, ByVal aUnidades As String, ByVal aUnidadesNC As String, ByVal aValorCaracteristica1 As String, ByVal aValorCaracteristica2 As String, ByVal aValorCaracteristica3 As String) As Integer
    Declare Function fAltaMovtoCaracteristicasUnidades_Param Lib "MGW_SDK.DLL" (ByVal aIdMovimiento As String, ByVal aUnidades As String, ByVal aTipoCambio As String, ByVal aSeries As String, ByVal aPedimento As String, ByVal aAgencia As String, ByVal aFechaPedimento As String, ByVal aNumeroLote As String, ByVal aFechaFabricacion As String, ByVal aFechaCaducidad As String) As Integer

    Declare Function fCalculaMovtoSerieCapa Lib "MGW_SDK.DLL" (ByVal aIdMovimiento As Integer) As Integer
    Declare Function fObtieneUnidadesPendientes Lib "MGW_SDK.DLL" (ByVal aConceptoDocto As String, ByVal aCodigoProducto As String, ByVal aCodigoAlmacen As String, ByRef aUnidades As String) As Integer
    Declare Function fObtieneUnidadesPendientesCarac Lib "MGW_SDK.DLL" (ByVal aConceptoDocto As String, ByVal aCodigoProducto As String, ByVal aCodigoAlmacen As String, ByVal aValorCaracteristica1 As String, ByVal aValorCaracteristica2 As String, ByVal aValorCaracteristica3 As String, ByRef aUnidades As String) As Integer
    Declare Function fModificaCostoEntrada Lib "MGW_SDK.DLL" (ByVal aIdMovimiento As String, ByVal aCostoEntrada As String) As Integer

    Declare Function fSetDatoMovimiento Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String) As Integer
    Declare Function fLeeDatoMovimiento Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer

    Declare Function fSetFiltroMovimiento Lib "MGW_SDK.DLL" (ByVal aIdDocumento As Integer) As Integer
    Declare Function fCancelaFiltroMovimiento Lib "MGW_SDK.DLL" () As Integer

    ' Bajo Nivel - Busqueda/Navegación
    Declare Function fBuscarIdMovimiento Lib "MGW_SDK.DLL" (ByVal aIdMovimiento As Integer) As Integer

    Declare Function fPosPrimerMovimiento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosUltimoMovimiento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosSiguienteMovimiento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosAnteriorMovimiento Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosMovimientoBOF Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosMovimientoEOF Lib "MGW_SDK.DLL" () As Integer

    ' ***** Funciones de Clientes / Proveedores *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fInsertaCteProv Lib "MGW_SDK.DLL" () As Integer
    'Declare Function fEditaCteProv Lib "MGW_SDK.DLL" () As Integer
    Declare Function fEditaCteProv Lib "MGW_SDK.DLL" (ByRef aIdCliente As Integer, ByVal lClienteProveedor As tClientes) As Integer
    Declare Function fAltaCteProv Lib "MGW_SDK.DLL" (ByRef aIdCliente As Integer, ByVal lClienteProveedor As tClientes) As Integer
    Declare Function fGuardaCteProv Lib "MGW_SDK.DLL" () As Integer
    Declare Function fBorraCteProv Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelarModificacionCteProv Lib "MGW_SDK.DLL" () As Integer

    Declare Function fEliminarCteProv Lib "MGW_SDK.DLL" (ByVal aCodCteProv As String) As Integer
    Declare Function fSetDatoCteProv Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String) As Integer
    Declare Function fLeeDatoCteProv Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer

    ' Bajo Nivel - Busqueda/Navegación
    Declare Function fBuscaCteProv Lib "MGW_SDK.DLL" (ByVal aCodCteProv As String) As Integer
    Declare Function fBuscaIdCteProv Lib "MGW_SDK.DLL" (ByVal aIdCteProv As Integer) As Integer

    Declare Function fPosPrimerCteProv Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosUltimoCteProv Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosSiguienteCteProv Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosAnteriorCteProv Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosBOFCteProv Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosEOFCteProv Lib "MGW_SDK.DLL" () As Integer

    ' ***** Funciones de Productos  *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fInsertaProducto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fEditaProducto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fGuardaProducto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fBorraProducto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelarModificacionProducto Lib "MGW_SDK.DLL" () As Integer

    Declare Function fEliminarProducto Lib "MGW_SDK.DLL" (ByVal aCodCteProv As String) As Integer
    Declare Function fSetDatoProducto Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String) As Integer
    Declare Function fLeeDatoProducto Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer

    Declare Function fRecuperaTipoProducto Lib "MGW_SDK.DLL" (ByRef aUnidades As Boolean, ByRef aSerie As Boolean, ByRef aLote As Boolean, ByRef aPedimento As Boolean, ByRef aCaracteristicas As Boolean) As Integer

    'Función de recosteo de productos
    Declare Function fRecosteoProducto Lib "MGW_SDK.DLL" (ByVal aCodigoProducto As String, ByVal aEjercicio As Integer, ByVal aPeriodo As Integer, ByVal aCodigoClasificacion1 As String, ByVal aCodigoClasificacion2 As String, ByVal aCodigoClasificacion3 As String, ByVal aCodigoClasificacion4 As String, ByVal aCodigoClasificacion5 As String, ByVal aCodigoClasificacion6 As String, ByVal aNombreBitacora As String, ByVal aSobreEscribirBitacora As Integer, ByVal aEsCalculoArimetico As Integer) As Integer

    Declare Function fRegresaPrecioVenta Lib "MGW_SDK.DLL" (ByVal aCodigoConcepto As String, ByVal aCodigoCliente As String, ByVal aCodigoProducto As String, ByRef aPrecioVenta As String) As Integer

    ' Bajo Nivel - Busqueda/Navegación
    Declare Function fBuscaProducto Lib "MGW_SDK.DLL" (ByVal aCodProducto As String) As Integer
    Declare Function fBuscaIdProducto Lib "MGW_SDK.DLL" (ByVal aIdProducto As Integer) As Integer

    Declare Function fPosPrimerProducto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosUltimoProducto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosSiguienteProducto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosAnteriorProducto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosBOFProducto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosEOFProducto Lib "MGW_SDK.DLL" () As Integer

    ' ***** Funciones de Direcciones  *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fInsertaDireccion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fEditaDireccion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fGuardaDireccion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelarModificacionDireccion Lib "MGW_SDK.DLL" () As Integer

    Declare Function fSetDatoDireccion Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String) As Integer
    Declare Function fLeeDatoDireccion Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer

    ' Bajo Nivel - Busqueda/Navegación
    Declare Function fBuscaDireccionEmpresa Lib "MGW_SDK.DLL" () As Integer
    Declare Function fBuscaDireccionCteProv Lib "MGW_SDK.DLL" (ByVal aCodCteProv As String, ByRef aTipoDireccion As String) As Integer
    Declare Function fBuscaDireccionDocumento Lib "MGW_SDK.DLL" (ByVal aIdDocumento As Integer, ByRef aTipoDireccion As String) As Integer

    Declare Function fPosPrimerDireccion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosUltimaDireccion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosSiguienteDireccion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosAnteriorDireccion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosBOFDireccion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosEOFDireccion Lib "MGW_SDK.DLL" () As Integer


    ' ***** Funciones de Existencias  *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fRegresaExistencia Lib "MGW_SDK.DLL" (ByVal aCodigoProducto As String, ByVal aCodigoAlmacen As String, ByVal aAnio As String, ByVal aMes As String, ByVal aDia As String, ByRef aExistencia As Double) As Integer
    Declare Function fRegresaExistenciaCaracteristicas Lib "MGW_SDK.DLL" (ByVal aCodigoProducto As String, ByVal aCodigoAlmacen As String, ByVal aAnio As String, ByVal aMes As String, ByVal aDia As String, ByVal aValorCaracteristica1 As String, ByVal aValorCaracteristica2 As String, ByVal aValorCaracteristica3 As String, ByRef aExistencia As Double) As Integer


    ' ***** Funciones de Costo Histórico  *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fRegresaCostoPromedio Lib "MGW_SDK.DLL" (ByVal aCodigoProducto As String, ByVal aCodigoAlmacen As String, ByVal aAnio As String, ByVal aMes As String, ByVal aDia As String, ByRef aCostoPromedio As String) As Integer
    Declare Function fRegresaUltimoCosto Lib "MGW_SDK.DLL" (ByVal aCodigoProducto As String, ByVal aCodigoAlmacen As String, ByVal aAnio As String, ByVal aMes As String, ByVal aDia As String, ByRef aUltimoCosto As String) As Integer
    Declare Function fRegresaCostoEstandar Lib "MGW_SDK.DLL" (ByVal aCodigoProducto As String, ByRef aCostoEstandar As String) As Integer
    Declare Function fRegresaCostoCapa Lib "MGW_SDK.DLL" (ByVal aCodigoProducto As String, ByVal aCodigoAlmacen As String, ByVal aUnidades As Double, ByRef aImporteCosto As String) As Integer


    ' ***** Funciones de Concepto Documento *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fLeeDatoConceptoDocto Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer
    Declare Function fRegresPorcentajeImpuesto Lib "MGW_SDK.DLL" (ByVal aIdConceptoDocumento As Integer, ByVal aIdClienteProveedor As Integer, ByVal aIdProducto As Integer, ByRef aPorcentajeImpuesto As Double) As Integer

    ' Bajo Nivel - Busqueda/Navegación
    Declare Function fBuscaConceptoDocto Lib "MGW_SDK.DLL" (ByVal aCodConcepto As String) As Integer
    Declare Function fBuscaIdConceptoDocto Lib "MGW_SDK.DLL" (ByVal aIdConcepto As Integer) As Integer

    Declare Function fPosPrimerConceptoDocto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosUltimaConceptoDocto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosSiguienteConceptoDocto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosAnteriorConceptoDocto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosBOFConceptoDocto Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosEOFConceptoDocto Lib "MGW_SDK.DLL" () As Integer


    ' ***** Funciones de Parámetros *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fLeeDatoParametros Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer


    ' ***** Funciones del Catálogo de Clasificaciones  *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fEditaClasificacion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fGuardaClasificacion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelarModificacionClasificacion Lib "MGW_SDK.DLL" () As Integer

    Declare Function fSetDatoClasificacion Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String) As Integer
    Declare Function fLeeDatoClasificacion Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer

    Declare Function fActualizaClasificacion Lib "MGW_SDK.DLL" (ByVal aClasificacionDe As Integer, ByVal aNumClasificacion As Integer, ByVal aNombreClasificacion As String) As Integer


    ' Bajo Nivel - Busqueda/Navegación
    Declare Function fBuscaClasificacion Lib "MGW_SDK.DLL" (ByVal aClasificacionDe As Integer, ByVal aNumClasificacion As Integer) As Integer
    Declare Function fBuscaIdClasificacion Lib "MGW_SDK.DLL" (ByVal aIdClasificacion As Integer) As Integer

    Declare Function fPosPrimerClasificacion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosUltimoClasificacion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosSiguienteClasificacion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosAnteriorClasificacion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosBOFClasificacion Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosEOFClasificacion Lib "MGW_SDK.DLL" () As Integer


    ' ***** Funciones del Catálogo de Valores de Clasificaciones *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fInsertaValorClasif Lib "MGW_SDK.DLL" () As Integer
    Declare Function fEditaValorClasif Lib "MGW_SDK.DLL" () As Integer
    Declare Function fGuardaValorClasif Lib "MGW_SDK.DLL" () As Integer
    Declare Function fBorraValorClasif Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelarModificacionValorClasif Lib "MGW_SDK.DLL" () As Integer

    Declare Function fEliminarValorClasif Lib "MGW_SDK.DLL" (ByVal aClasificacionDe As Integer, ByVal aNumClasificacion As Integer, ByVal aCodValorClasif As String) As Integer
    Declare Function fSetDatoValorClasif Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String) As Integer
    Declare Function fLeeDatoValorClasif Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer

    ' Bajo Nivel - Busqueda/Navegación
    Declare Function fBuscaValorClasif Lib "MGW_SDK.DLL" (ByVal aClasificacionDe As Integer, ByVal aNumClasificacion As Integer, ByVal aCodValorClasif As String) As Integer
    Declare Function fBuscaIdValorClasif Lib "MGW_SDK.DLL" (ByVal aIdValorClasif As Integer) As Integer

    Declare Function fPosPrimerValorClasif Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosUltimoValorClasif Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosSiguienteValorClasif Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosAnteriorValorClasif Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosBOFValorClasif Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosEOFValorClasif Lib "MGW_SDK.DLL" () As Integer


    ' ***** Funciones del Catálogo de Unidades de Medida y Peso  *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fInsertaUnidad Lib "MGW_SDK.DLL" () As Integer
    Declare Function fEditaUnidad Lib "MGW_SDK.DLL" () As Integer
    Declare Function fGuardaUnidad Lib "MGW_SDK.DLL" () As Integer
    Declare Function fBorraUnidad Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelarModificacionUnidad Lib "MGW_SDK.DLL" () As Integer

    Declare Function fEliminarUnidad Lib "MGW_SDK.DLL" (ByVal aNombreUnidad As String) As Integer
    Declare Function fSetDatoUnidad Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String) As Integer
    Declare Function fLeeDatoUnidad Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer

    ' Bajo Nivel - Busqueda/Navegación
    Declare Function fBuscaUnidad Lib "MGW_SDK.DLL" (ByVal aNombreUnidad As String) As Integer
    Declare Function fBuscaIdUnidad Lib "MGW_SDK.DLL" (ByVal aIdUnidad As Integer) As Integer

    Declare Function fPosPrimerUnidad Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosUltimoUnidad Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosSiguienteUnidad Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosAnteriorUnidad Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosBOFUnidad Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosEOFUnidad Lib "MGW_SDK.DLL" () As Integer

    ' ***** Funciones del Catálogo de Agentes *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fInsertaAgente Lib "MGW_SDK.DLL" () As Integer
    'Declare Function fEditaAgente Lib "MGW_SDK.DLL" () As Long
    Declare Function fEditaAgente Lib "MGW_SDK.DLL" () As Integer
    Declare Function fGuardaAgente Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelarModificacionAgente Lib "MGW_SDK.DLL" () As Integer

    Declare Function fLeeDatoAgente Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer
    Declare Function fSetDatoAgente Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String) As Integer

    ' Bajo Nivel - Busqueda/Navegación
    Declare Function fBuscaIdAgente Lib "MGW_SDK.DLL" (ByVal aIdAgente As Integer) As Integer
    Declare Function fBuscaAgente Lib "MGW_SDK.DLL" (ByVal aCodigoAgente As String) As Integer

    Declare Function fPosPrimerAgente Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosUltimoAgente Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosSiguienteAgente Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosAnteriorAgente Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosBOFAgente Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosEOFAgente Lib "MGW_SDK.DLL" () As Integer


    ' ***** Funciones del Catálogo de Almacenes *****
    ' Bajo Nivel - Lectura/Escritura
    Declare Function fInsertaAlmacen Lib "MGW_SDK.DLL" () As Integer
    Declare Function fEditaAlmacen Lib "MGW_SDK.DLL" () As Integer
    Declare Function fGuardaAlmacen Lib "MGW_SDK.DLL" () As Integer
    Declare Function fCancelarModificacionAlmacen Lib "MGW_SDK.DLL" () As Integer

    Declare Function fLeeDatoAlmacen Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String, ByVal aLen As Integer) As Integer
    Declare Function fSetDatoAlmacen Lib "MGW_SDK.DLL" (ByVal aCampo As String, ByVal aValor As String) As Integer

    ' Bajo Nivel - Busqueda/Navegación
    Declare Function fBuscaIdAlmacen Lib "MGW_SDK.DLL" (ByVal aIdAlmacen As Integer) As Integer
    Declare Function fBuscaAlmacen Lib "MGW_SDK.DLL" (ByVal aCodigoAlmacen As String) As Integer

    Declare Function fPosPrimerAlmacen Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosUltimoAlmacen Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosSiguienteAlmacen Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosAnteriorAlmacen Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosBOFAlmacen Lib "MGW_SDK.DLL" () As Integer
    Declare Function fPosEOFAlmacen Lib "MGW_SDK.DLL" () As Integer
End Class
